package com.itcoon.transform4j.demo.web.controller;

import com.itcoon.common.web.core.response.ApiResponse;
import com.itcoon.transform4j.demo.web.command.AuthorCommand;
import com.itcoon.transform.starter.Transformer;
import com.itcoon.transform4j.demo.web.vo.AuthorVIO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Miaoxia Yu
 * @date 2020-11-06
 */
@Api(tags = "05_assemble_进阶篇", description = "使用转换器编集")
@RestController
@RequestMapping("/api")
public class ComplexConvertAssembleController {

    @ApiOperation("创建作者")
    @PostMapping("/author")
    public ApiResponse<AuthorVIO> createAuthor(@RequestBody AuthorCommand command){
        AuthorVIO authorVIO = Transformer.to(AuthorVIO.class).apply(command).done();
        return ApiResponse.createSuccess(authorVIO);
    }
}
